home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2471 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.5 KB  |  70 lines

  1. Newsgroups: comp.lang.c++
  2. Path: ned.cray.com!phaser!aztec
  3. From: aztec@cray.com (Joel Garcia-Trevino  {x66457 CF/DEV})
  4. Subject: Multiple Abstract Classes Question
  5. Message-ID: <1996Jan17.160425.6063@ned.cray.com>
  6. Nntp-Posting-Host: phaser.cray.com
  7. Reply-To: aztec@cray.com
  8. Organization: Cray Research, Inc.
  9. Date: 17 Jan 96 16:04:25 CST
  10.  
  11.  
  12.  Can I or is it a good idea to have multiple abstract classes to start building
  13. a class hierarchy?
  14.  
  15.   Example of the base (abstract) classes:
  16.  
  17.        class base_type; 
  18.  
  19.        class base_net {
  20.         public:
  21.          virtual char         *get_name() = 0;    // Gets the name
  22.          virtual base_type    *get_type() = 0;    // Gets pointer to type
  23.        };
  24.  
  25.        class base_type {
  26.         public:
  27.          virtual char *get_type() = 0;            // Gets type name 
  28.        };
  29.  
  30.  
  31.   The final classes would look something like:
  32.  
  33.       class type;
  34.  
  35.       class net: public base_net {
  36.         private:
  37.          char *name;
  38.          type *type_pntr;
  39.  
  40.         public:
  41.          char *get_name() { ..... };
  42.          type *get_type() { ..... }; 
  43.  
  44.       };
  45.  
  46.      class type: public base_type {
  47.        private:
  48.         char *type_name;
  49.  
  50.        public:
  51.         char *get_type() { ..... };
  52.  
  53.      };
  54.  
  55.  
  56.  Does it make sense to do it this way?
  57.         
  58.  The reason why I want to do this is because there will be different types
  59. of nets that I will need to work with. I don't know if there will be
  60. different types of "type" but I thought why not make them all abstract. ???
  61.  
  62.  
  63.  Thanks in advance for your help,
  64.  
  65.  
  66.              Joel Garcia
  67.  
  68.  
  69.  
  70.